package com.baizhi.service.impl;

import com.baizhi.dao.CmfzAdminDao;
import com.baizhi.dao.CmfzBannerDao;
import com.baizhi.entity.CmfzAdmin;
import com.baizhi.entity.CmfzBanner;
import com.baizhi.entity.CmfzMenu;
import com.baizhi.service.AdminService;
import com.baizhi.service.BannerService;
import com.baizhi.service.CmfzMenuService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Service
public class BannerServiceImpl implements BannerService {

    @Resource
    private CmfzBannerDao cmfzBannerDao;


    @Override
    public Page<CmfzBanner> selectAll(Integer page, Integer limit) {
        //1.创建一个分页对象 封装分页数据
        Page<CmfzBanner> bannerPage = new Page<>(page, limit);
        //2.使用分页查询的方法
        Page<CmfzBanner> cmfzBannerPage = cmfzBannerDao.selectPage(bannerPage, null);

        return cmfzBannerPage;
    }

    @Override
    public CmfzBanner showOne(Integer id) {

        return cmfzBannerDao.selectById(id);
    }

    @Override
    public void insert(CmfzBanner cmfzBanner) {
        try {
            cmfzBannerDao.insert(cmfzBanner);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void delete(Integer id) {
        try {
            cmfzBannerDao.deleteById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void update(CmfzBanner cmfzBanner) {
        try {
            cmfzBannerDao.update(cmfzBanner,null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void deleteAll(List<CmfzBanner> ids) {
        try {
            cmfzBannerDao.deleteBatchIds(ids);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
